﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using proRFID_DiemDanh.Chung;

namespace proRFID_DiemDanh.GiaoVien
{
    public partial class ThemGiaoVien : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Load_DDL_Khoa();
                txt_HoGV.Focus();
            }
        }
        void Load_DDL_Khoa()
        {
            DataTable dt = new DataTable();
            dt = mdGiaoVien.sp_Khoa_DDL();
            ddl_Khoa.DataSource = dt;
            ddl_Khoa.DataValueField = "MAKHOA";
            ddl_Khoa.DataTextField = "TENKHOA";
            ddl_Khoa.DataBind();
        }

        protected void Imgcmd_ThemGV_Click(object sender, ImageClickEventArgs e)
        {
            DataTable dt = new DataTable();
            dt = mdGiaoVien.sp_GiaoVien_Insert(txt_HoGV.Text.Trim(), txt_TenGV.Text.Trim(), Convert.ToInt16(ddl_Khoa.SelectedValue));

            if (dt.Rows[0]["ErrCode"].ToString() == "0")
            {
                mdMain.OKCancelBox(this, dt.Rows[0]["ErrMsg"].ToString() + "\\nBạn có muốn thêm dữ liệu nữa không?", "/GiaoVien/GiaoVien.aspx");
                txt_HoGV.Text = "";
                txt_TenGV.Text = "";
                ddl_Khoa.SelectedIndex = 0;
                txt_HoGV.Focus();
            }
            else
                mdMain.OKBox(this,dt.Rows[0]["ErrMsg"].ToString(),"/GiaoVien/GiaoVien.aspx");
        }
    }
}